package com.wyh.domain.po.g3po;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

@Getter
public class BillingItemsEnum {

    public enum BillingType {
//        NULL(-1, "未知"),
        PERIODIC(0, "周期性计费"),
        THREE_METER(1, "三表类计费"),
        TEMPORARY(2, "临时性计费"),
        DEPOSIT(3, "保证金计费"),
        PREPAID(4, "预存计费");

        private int code;
        private String description;

        BillingType(int code, String description) {
            this.code = code;
            this.description = description;
        }

        //查询其中一个
        public static String getByCode(int code) {
            for (BillingType type : BillingType.values()) {
                if (type.code == code) {
                    return type.getDescription();
                }
            }
            return PERIODIC.getDescription();
        }
        //查询所有
        public static List<String> getAllBillingTypes() {
            List<String> billingType = new ArrayList<>();
            for (BillingType type : BillingType.values()) {
                billingType.add(type.getDescription());
            }
            return billingType;
        }

        public int getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }
    }

    public enum SpecialName {
        WATER(0, "水费预存"),
        ELECTRICITY(1, "电费预存"),
        GAS(2, "气费预存"),
        PROPERTY_FEE(3,"物业费预存"),
        UTILITY_COSTS(4,"通用预存");

        private int code;
        private String description;

        SpecialName(int code, String description) {
            this.code = code;
            this.description = description;
        }
            //获取其中一个
        public static String getByCode(int code) {
            for (SpecialName name : SpecialName.values()) {
                if (name.code == code) {
                    return name.getDescription();
                }
            }
            return WATER.getDescription();
        }

        //获取所有 //
        public static List<String> getAllSpecialNames(Integer id) {
            List<String> specialNames = new ArrayList<>();
            if (id==4){
                for (SpecialName name : SpecialName.values()) {
                        specialNames.add(name.getDescription());
                }
            }else {
                for (SpecialName name : SpecialName.values()) {
                    if (name.getCode()!=4){
                        specialNames.add(name.getDescription());
                    }
                    else {
                        break;
                    }
                }
            }

            return specialNames;
        }

        public int getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }
    }

    public enum ThreeMeterType {
        WATER(0, "水费"),
        ELECTRICITY(1, "电费"),
        GAS(2, "气费");

        private int code;
        private String description;

        ThreeMeterType(int code, String description) {
            this.code = code;
            this.description = description;
        }

        public static String getByCode(int code) {
            for (ThreeMeterType type : ThreeMeterType.values()) {
                if (type.code == code) {
                    return type.getDescription();
                }
            }
            return null;
        }

        public static List<String> getAllThreeMeterTypes() {
            List<String> threeMeterType = new ArrayList<>();
            for (ThreeMeterType type : ThreeMeterType.values()) {
                threeMeterType.add(type.getDescription());
            }
            return threeMeterType;
        }

        public int getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }
    }


}
